<%@ page import="dao.Dao" %>
<%@ page import="domain.User" %>
<%@ page import="domain.Goods" %><%--
  Created by IntelliJ IDEA.
  User: wangh
  Date: 2020/12/25
  Time: 14:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>加入购物车信息</title>

    <!-- 1. 导入CSS的全局样式 -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="js/jquery-3.3.1.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="js/bootstrap.min.js"></script>
    <script>
        function checkForm(){
            if(checkNull()){
                document.getElementById("form").submit();
            }else {
                return false;
            }
        }
        function checkNull(){
            let elementById = document.getElementById("cnumber");
            console.log(elementById.value);
            if(elementById.value.length==0){
                alert("输入的商品数量不能为空！");
                return false;
            }else {
                return true;
            }
        }
    </script>
</head>
<body style="background-color: #F2F2F2">
<div class="logoBar"
     style="height: 75px;background: #1d7ad9;font-size: 35px;font-weight: bolder;padding-left: 100px;padding-top: 12px;color: white;">
    电脑销售平台
</div>
<div class="container" style="width: 400px;background-color: #ffffff;margin-top: 20px;border-radius: 10px;">
    <h3 style="text-align: center;">加入购物车信息</h3>
    <form action="${pageContext.request.contextPath}/addShoppingCarServlet?sid=${good_shoppingCar.cid}&suserid=${user_shoppingCar.id}"
          method="post" id="form" onSubmit="return checkForm()">
        <div class="form-group">
            <label for="cname_no1">商品品牌：</label>
            <input type="text" name="cname_no1" class="form-control" id="cname_no1"
                   value="${good_shoppingCar.cname_no1}" readonly="readonly"/>
        </div>
        <div class="form-group">
            <label for="cname">商品名称：</label>
            <input type="text" name="cname" class="form-control" id="cname"
                   value="${good_shoppingCar.cname}" readonly="readonly"/>
        </div>
        <div class="form-group">
            <label for="cprice">商品价格：</label>
            <c:if test="${good_shoppingCar.cdiscounte==10}">
                <input type="text" name="cprice" class="form-control" id="cprice" value="${good_shoppingCar.cprice}" readonly="readonly"/>
            </c:if>
            <c:if test="${good_shoppingCar.cdiscounte!=10}">
                <input type="text" name="cprice" class="form-control" id="cprice"
                       value="${good_shoppingCar.cprice*good_shoppingCar.cdiscounte/10}" readonly="readonly"/>
            </c:if>
        </div>
        <div class="form-group">
            <label for="cnumber">商品数量：</label>
            <input type="text" name="cnumber" class="form-control" id="cnumber" placeholder="请输入加入购物车的商品数量"/>
        </div>
        <div class="form-group" style="text-align: center;margin-top: 10px;">
            <input class="btn btn btn-primary" type="submit" value="提交">
        </div>
    </form>
    <div class="alert alert-warning alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
                aria-hidden="true">&times;</span></button>
        <strong>提示信息:</strong>${AddShoppingCarInfo}
    </div>
</div>
</body>
</html>
